<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        .layui-form-item .layui-input-inline {
            width: 300px !important;
        }

        .alert-msg {
            text-align: center;
            color: red;
            margin-top: 10px;
        }
    </style>
    <script src="/assets/jquery/jquery-3.1.1.min.js"></script>
    <script src="/assets/layui-2.9.18/layui.js"></script>
    <link rel="stylesheet" href="/assets/layui-2.9.18/css/layui.css">
    <link rel="stylesheet" href="/assets/layui-2.9.18/css/admin.css">
    <script src="/assets/september/common.js"></script>
    <link rel="stylesheet" href="/assets/pages/form.css">

    <script src="/assets/september/crypto.js"></script>
    <script src="/assets/september/aes.js"></script>
</head>
<body style="background:white">

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <form id="form" class="layui-form" style="">
        <input type="hidden" value="${id}" name="id"/>
        <div class="layui-form-item">
            <label class="layui-form-label">旧密码 <em class="required">*</em></label>
            <div class="layui-input-inline">
                <input type="password" name="oldPwd" lay-verify="password" autocomplete="off" class="layui-input"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码 <em class="required">*</em></label>
            <div class="layui-input-inline">
                <input type="password" name="newPwd" lay-verify="password" autocomplete="off" class="layui-input"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码 <em class="required">*</em></label>
            <div class="layui-input-inline">
                <input type="password" name="newPwdRepeat" lay-verify="password" autocomplete="off"
                       class="layui-input"/>
            </div>
        </div>
    </form>
    <div class="layui-form-item">
        <input type="button" class="layui-btn layui-btn-normal" style="float: right" lay-submit=""
               lay-filter="submit_button" value="确认"/>
    </div>
</div>
<script>

    layui.use(function () {
        var form = layui.form;

        /* 自定义验证规则 */
        //addVerify(form);

        form.on("submit", function (data) {
            prepareFormData(data);
            data.field.oldPwd = encrypt(data.field.oldPwd);
            data.field.newPwd = encrypt(data.field.newPwd);
            data.field.newPwdRepeat = encrypt(data.field.newPwdRepeat);
            sajax({
                type: "POST",
                url: "/userPermission/systemUser/doResetMyPwd",
                data: data.field,
                dataType: 'json'
            }).done(function (data) {
            	if (data.code == 0) {
					layer.msg('保存成功，系统即将退出，请重新登录。',{shade: [0.1,'#fff'], time:1600});
					setTimeout(function(){
						// 让cookie失效
			        	setCookie('_lastRequestUrl', '', 1);
			        	window.top.location = "/login";
					},2000);
				}
            });
        });
    });

</script>
</body>
</html>
